<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>资源管理</title>
<script type="text/javascript" src="/j-tool/jquery.js"></script>
<style>
	html,body,div,ul{margin:0;padding:0;}
	body{background:#F0F0F0;}
	li{list-style-type: none;}
	.bread{color:red;font-size:12px;height:20px;line-height:20px;padding-left:10px;background:#E9E9E9;border-bottom: 1px solid #B7C2C9;}
	td{font-size:12px;height:25px;padding:0 15px;}
	.manageBox{margin-left:20px;margin-top:20px;border-bottom: 1px solid #B7C2C9;}
	#doline,#ajaxpage,table{float:left;}
	.searchBox{border-left:1px solid #B7C2C9;margin-top:460px;}
	#ajaxpage,#doline{height: 22px;display:inline;padding:10px 12px;}
	
	#doline li{float:left;display:inline;}
	#ajaxpage li{float:left;border:1px solid #B7C2C9;margin:2px;width:16px;text-align:center;font-size:14px;display:inline;}
	#ajaxpage li span{float:left;width:100%;background:#E9E9E9;cursor:pointer;}
	#ajaxpage .caheTag span{background:black;color:white;}
	.clear{clear:both;}
	.backcaver{width:100%;filter:alpha(opacity=75);/* IE */ -moz-opacity:0.75;opacity: 0.75;background:#CDCDCD;top:0;position:absolute;}
	.alertbox{background:white;width:70%;top:5%;left:15%;border: 1px solid #B7C2C9;position:absolute;}
	.s{display:none;}
	#alertbox h4,.but{text-align:center;}
	.but{padding-top:10px;}
</style>
<body>
	<div class='bread'>资源管理->管理</div>
	<div class="manageBox">
		<div class="content">
			<table id="sourceList">
				<tr><td>ID</td><td>标题</td><td>资源</td><td><a href="javascript:;" onclick="choseAll();">全选</a></td></tr>
				<!--{foreach from=$data item=val}-->
				<tr><td><!--{$val.id}--></td><td><!--{$val.name|substr:0:15:false}--></td><td><a href="<!--{$val.qvod_path}-->"><!--{$val.from_path}--></a></td><td><input type="checkbox" name="chose[<!--{$val.id}-->]" value="<!--{$val.id}-->"/></td></tr>
				<!--{/foreach}-->
			</table>
			<table class="searchBox">
				<form action="" method="post" onsubmit="return false;" id="searchForm">
					<tr>
						<td>ID:</td><td><input type="text" name="id"/></td>
					</tr>
					<tr>
						<td>标题:</td><td><input type="text" name="name"/></td>
					</tr>
					<tr>
						<td>类型:</td><td><input type="text" name="type"/></td>
					</tr>
					<tr>
						<td>时间:</td><td><input type="text" name="sTime"/>&nbsp;--&nbsp;<input type="text" name="eTime"/></td>
					</tr>
					<tr><td></td><td><input type="submit" value="搜索" style="height:24px;" onclick="search(1);"/></td></tr>
				</form>
			</table>
			<div class="clear"></div>
		</div>
		<div>
			<ul id="ajaxpage">
				<li class="caheTag"><span onclick="search(1);">1</span></li>
				<li><span onclick="search(2);">2</span></li>
				<li><span onclick="search(3);">3</span></li>
				<li><span onclick="search(4);">4</span></li>
				<li><span onclick="search(5);">5</span></li>
				<li><span onclick="search(6);">6</span></li>
				<li><span onclick="search(7);">7</span></li>
				<li><span onclick="search(8);">8</span></li>
				<li><span onclick="search(9);">9</span></li>
				<li><span onclick="search(10);">10</span></li>
				<li><span onclick="search(11);">11</span></li>
			</ul>
			<ul id="doline">
				<li><button onclick="updata();">修改</button>&nbsp;</li>
				<li>&nbsp;<button onclick="del();">删除</button></li>
			</ul>
			<div class="clear"></div>
		</div>
	</div>
	<div class="backcaver s"></div>
	<div class="alertbox s" id="alertbox"></div>
</body>
<script>
	var jsond,dataIds = new  Array();
	function closealert()
	{
		$('.s').hide();
	}

	function updata()
	{
		//var val = $("input:checked").serialize();
		//dataIds.push(6,7);
		var val = $("input:checked").val();
		if(val)
		{
			$.ajax({
			   type: "POST",
			   url: "",
			   data: 'id='+val+'&tp=update',
			   success: function(msg)
			   {
					if(msg != 'null')
					{	
						var data = $.parseJSON(msg);
							data = data[0];
							jsond = '{"id":"'+data.id+'","name":"'+data.name+'","qvod_path":"'+data.qvod_path+'","from_path":"'+data.from_path+'","qvod_type":"'+data.qvod_type+'","new_qvod_path":"'+data.new_qvod_path+'"}';
						var html = '<h4>'+data.name+'</h4>';
							html += '<table width="100%">';
							html += '<tr><td width="15%">链接地址：</td><td><a href="http://www.313zy.com'+data.from_path+'">'+data.from_path+'</td></tr>';
							html += '<tr><td>类别：</td><td>'+data.qvod_type+'</td></tr>';
							html += '<tr><td>原资源地址：</td><td>'+data.qvod_path+'</td></tr>';
							html += '<tr><td>新资源地址：</td><td>'+data.new_qvod_path+'</td></tr>';
							html += '<tr><td>图片：</td><td>'+data.name+'</td></tr>';
							html += '<tr><td colspan="2" align="center"><input type="button" value="更新" onclick="doupdate();"/><input type="button" value="取消" onclick="closealert();"/></td></tr>';
							html += '</table>';
						$('#alertbox').html(html);
						$('.s').show();
					}					
			   }
			});
		}
	}
	
	function doupdate()
	{
		$.ajax({
			   type: "POST",
			   url: "",
			   data: 'json='+jsond+'&tp=doupdate',
			   success: function(msg)
			   {
					if(msg != 'null')
					{
						$('.s').hide();
					}					
			   }
			});
	}
	
	function del()
	{	
		var value = obj[key];
	}

	function choseAll()
	{
		$('input[type=checkbox]').attr('checked',true);
	}

	function search(p)
	{
		$.ajax({
		   type: "POST",
		   url: "",
		   data: $("#searchForm").serialize()+'&page='+p,
		   success: function(json)
		   {
				if(json == 'null')
				{
					alert('没有更多符合条件的数据');
				}else{
					var html = "<tr><td>ID</td><td>标题</td><td>资源</td><td><a href='javascript:;' onclick='choseAll();'>全选</a></td></tr>";
					var data = $.parseJSON(json);
					for(var i=0;i<data.length;i++)
					{
						html += "<tr><td>"+data[i].id+"</td><td>"+data[i].name.substr(0,16)+"</td><td><a href='"+data[i].qvod_path+"'>"+data[i].from_path+"</a></td><td><input type='checkbox' name='chose["+data[i].id+"]' value='"+data[i].id+"'/></td></tr>"
					}
					$('#sourceList').html(html);
					$('#ajaxpage > li').eq(p-1).addClass('caheTag').siblings().removeClass('caheTag');
				}
		   }
		});
	}

	var dh = $('body').height();
		$('.backcaver').height(dh);
		$('.alertbox').height(dh*0.9);
</script>
</html>